package my.learnDB.sdjpa.dao;

import my.learnDB.sdjpa.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * spring DATA JPA使用SQL查询
 */
public interface CUserUseSQL extends JpaRepository<User, Integer>, JpaSpecificationExecutor<User> {

    @Query(value = "select  * from user where id = ?1", nativeQuery = true)
        // 本土化，原生查询
    User findByIdUseSQL(Integer id);


    @Query(value = "select * from user where username like ?1", nativeQuery = true)
    List<User> likeNameQuery(String name);
    // likeNameQuery("小%");
    // likeNameQuery("小_");
}
